package org.yankun.exam4j.security.ip.service.impl;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import org.yankun.exam4j.common.daobase.DaoBase;
import org.yankun.exam4j.security.ip.service.IpService;

@Service
public class IpServiceImpl implements IpService {
	
	private static final Logger log = Logger.getLogger(IpServiceImpl.class);
	
	@Resource
	private DaoBase dao;


	@Override
	public boolean isBlack(String ip) {
		boolean black=false;
//		String sql = "select count(1) from Iplist where valid=0 and ip=?";
//		
//		int count = dao.getJdbcTemplate().queryForInt(sql, new Object[]{ip});
//		
//		if(count != 0){
//			black = true;
//			log.info("黑名单中IP:"+ip+"试图访问");
//		}
		return black;
	}

	@Override
	public boolean isWhite(String ip) {
		boolean white=false;
//		String sql = "select count(1) from Iplist where valid=1 and ip=?";
//		
//		int count = dao.getJdbcTemplate().queryForInt(sql, new Object[]{ip});
//		
//		if(count != 0){
//			white = true;
//			log.info("IP:"+ip+"正在访问系统核心功能");
//		}
		return white;
	}

}
